package com.dingreading.cloud.web.service.impl;

import com.dingreading.cloud.web.entity.TellHistoryLog;
import com.dingreading.cloud.web.entity.table.TellHistoryLogTableDef;
import com.dingreading.cloud.web.mapper.TellHistoryLogMapper;
import com.dingreading.cloud.web.service.TellHistoryLogService;
import com.mybatisflex.core.query.QueryWrapper;
import org.springframework.stereotype.Service;

/**
 *  服务层实现。
 *
 * @author Administrator
 * @since 2024-04-07
 */
@Service
public class TellHistoryLogServiceImpl extends BaseServiceImpl<TellHistoryLogMapper, TellHistoryLog, TellHistoryLogTableDef> implements TellHistoryLogService {

    @Override
    protected TellHistoryLogTableDef getTable() {
        return TellHistoryLogTableDef.tellHistoryLog;
    }

    @Override
    public TellHistoryLog getLastVideLog(String openid) {
        QueryWrapper wrapper = QueryWrapper.create()
                .where(table.openid.eq(openid).and(table.time.gt(0)))
                .orderBy(table.id.desc());

        return getMapper().selectOneByQuery(wrapper);
    }
}
